package cn.bonoon.kernel.web.components;

import cn.bonoon.handler.impl.StandardAutoManager;
import cn.bonoon.kernel.descriptors.UIPropertyAccessor;
import cn.bonoon.kernel.web.annotations.AjaxTreeLoader;
import cn.bonoon.kernel.web.annotations.AutoDataLoader;
import cn.bonoon.kernel.web.annotations.components.AsComboTree;
import cn.bonoon.kernel.web.handlers.loader.ComboAutoLoaderHandler;
import cn.bonoon.kernel.web.handlers.loader.ComboTreeAjaxAutoLoaderHandler;
import cn.bonoon.kernel.web.handlers.loader.ComboTreeAutoLoaderHandler;
import cn.bonoon.kernel.web.html.form.ComponentPropertyParser;

public class ComboTreeComponent extends AbstractComboComponent{
	
	public ComboTreeComponent(ComponentPropertyParser property, UIPropertyAccessor accessor, AsComboTree asComboTree) {
		super("buptreecombo", asComboTree.value(), property, accessor, asComboTree.reload());
	}
	
	@Override
	protected ComboAutoLoaderHandler builderHandler(StandardAutoManager builderInitializer, AutoDataLoader autoLoader)throws Throwable {
		if(accessor.isAnnotationPresent(AjaxTreeLoader.class)){
			return new ComboTreeAjaxAutoLoaderHandler(builderInitializer, autoLoader, accessor.getField());
		}
		return new ComboTreeAutoLoaderHandler(builderInitializer, autoLoader, accessor.getField());
	}

}
